/*
 * Created: Author: Aléx Carvalho / Date: Feb 9, 2015
 * 
 * Changed: $Author: ac280593@gmail.com $ / $Date: 2015-05-19 01:08:49 -0300 (Tue, 19 May 2015) $
 */
package com.cpm.wrapper;

import com.cpm.aggregate.Attribute;
import javax.persistence.Embeddable;

@Embeddable
public class Result implements Attribute<Double> {

    private Double result;

    public Result() {
    }

    public Result(Double result) {
        this.result = result;
    }

    @Override
    public Double getValue() {
        return result;
    }

    public Result plus(Result value) {
        return plus(value.getValue());
    }

    public Result plus(Double value) {
        value = result != null ? value + result : value;

        return new Result(value);
    }

    public Result divideBy(Double value) {
        return new Result(result != null ? result / value : null);
    }

    @Override
    public String toString() {
        return String.valueOf(result);
    }
}
